package com.pid.customerflow.instener;

import com.pid.common.utils.spring.SpringUtils;
import com.pid.customerflow.domain.WorkflowBigcustomer;
import com.pid.customerflow.service.IWorkflowBigcustomerService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;

public class CustomerflowEndStateListener implements ExecutionListener {
    private Expression state;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        WorkflowBigcustomer workflowBigcustomer = new WorkflowBigcustomer();
        workflowBigcustomer.setId(delegateExecution.getProcessInstanceBusinessKey());
        workflowBigcustomer.setState(state.getValue(delegateExecution).toString());
        SpringUtils.getBean(IWorkflowBigcustomerService.class).updateWorkflowBigcustomer(workflowBigcustomer);
    }
}
